package com.example.administrator.coldlain.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.administrator.coldlain.fragment.Fragment1;
import com.example.administrator.coldlain.fragment.Fragment2;
import com.example.administrator.coldlain.fragment.Fragment3;

public  class FragmentAdapter extends FragmentPagerAdapter {

    private Fragment1 fgWeChat;
    private Fragment2 fgContacts;
    private Fragment3 fgDiscovery;
    private Fragment3 fgMe;

    public FragmentAdapter(FragmentManager fm) {

        super(fm);
        fgWeChat=new Fragment1();
        fgContacts=new Fragment2();
        fgDiscovery=new Fragment3();
        fgMe=new Fragment3();
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment=null;

        switch (position){
            case 0:
                fragment=fgWeChat;
                break;
            case 1:
                fragment=fgContacts;
                break;
            case 2:
                fragment=fgDiscovery;
                break;
            case 3:
                fragment=fgMe;
                break;
        }

        return fragment;
    }

    @Override
    public int getCount() {
        return 4;
    }
}
